﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Espam.Idiomas.Decimo.Tesis.Datos;
using System.Data;
using System.Data.SqlClient;

namespace Espam.Idiomas.Decimo.Tesis.Negocio
{
    public  class Roles
    {
        public int idRol { get; set; }
        public string rol { get; set; }

    }
    public class ListadoRoles
    {
        public List<Roles> GetRoles()
        {
            BaseDatos oBase = new BaseDatos();
            List<Roles> lista = new List<Roles>();
            SqlDataReader reader;
            try
            {
                string consulta = string.Format("sp_getRoles");
                SqlCommand comando = new SqlCommand(consulta, oBase.conexion);
                comando.CommandType = CommandType.StoredProcedure;
                oBase.Conectar();
                reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    Roles oRol = new Roles();
                    oRol.idRol = reader.GetInt32(0);
                    oRol.rol = reader.GetString(1);
                    lista.Add(oRol);
                }
            }
            catch (Exception)
            {
             throw;
            }
            finally
            {
                oBase.CerrarConexion();
            }
            return lista;
        }
    }
}
